<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2017/5/7
  Time: 10:05
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%--解析表达式--%>
<%@ page isELIgnored="false" %>
<%--引入jstl--%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%--引入springMVC form--%>
<%@ taglib prefix="sf" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="page" uri="/xianzhiOA/pageTag" %>
<%@ taglib prefix="p" uri="/xianzhiOA/powerTag" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <title>模块一览</title>
    <script type="application/javascript">
        function edit() {
            var  projectForm = document.getElementById("moduleForm");
            projectForm.action = "${pageContext.request.contextPath}/Module/moduleEdit.emp";
            projectForm.submit();
        }
        function pToSub(page) {
            if(page!=undefined){
                var pageInp = document.getElementById("page");
                pageInp.value = page;
                var form = document.getElementById("moduleForm");
                form.submit();
            }
        }
        function deleteCheck(id) {
            if (confirm("确定要删除吗")) {
                window.location.href = "${pageContext.request.contextPath}/Module/deleteModule.emp?moduleId="+id;
            }
        }
        window.onload = function () {
            if('${open}'=='1'){
                var addBox = document.getElementById("addBox");
                var selBox = document.getElementById("selBox");
                selBox.style.display = "none";
                addBox.style.display = "block";
            }
        }
    </script>
</head>
<body>
<!--头部开始-->
<jsp:include page="headerBack.jsp"></jsp:include>
<!-- 导航 -->
<jsp:include page="leftBack.jsp"></jsp:include>
<!--内容页-->
<div class="main">
    <!--内容页头部-->
    <div class="page-header">
        <div class="pull-left">
            <ol class="breadcrumb visible-sm visible-md visible-lg">
                <li><a href="${pageContext.request.contextPath}/Login/goHomePage"><i class="icon fa fa-home"></i>主页</a></li>
                <li class="active"><i class="fa fa-pencil"></i>模板</li>
            </ol>
        </div>
        <div class="pull-right">
            <h2>主页</h2>
        </div>
    </div>
        <!--form表单-->
        <sf:form id="moduleForm" action="${pageContext.request.contextPath}/Module/selModuleAll.emp" modelAttribute="module"
                 method="post" class="search1">
            <c:if test="${open==1}">
                <div style="height: 40px">
                <a href="${pageContext.request.contextPath}/Module/selModuleAll.emp"  class="three btn btn-primary">返回</a>
                    <p:power jspPower="模块：添加">
                <button onclick="edit()" type="button" class="three btn btn-primary">添加</button>
                    </p:power>
                    <p:power jspPower="模块：修改">
                <a  href="${pageContext.request.contextPath}/Module/moduleEdit.emp?moduleId=${module.moduleId}" class="three btn btn-primary">修改</a>
                    </p:power>
                </div>
            </c:if>
            <c:if test="${open!=1}">
            <div style="height: 40px">
                <p:power jspPower="模块：添加">
                    <button onclick="edit()" type="button" class="three btn btn-primary">添加</button>
                </p:power>
                <a href="${pageContext.request.contextPath}/Module/selModuleAll.emp" class="three btn btn-primary">重置</a></div>
            <input type="hidden" id="page" name="page" value="${page}"/><!--当前页-->
            <input type="hidden" id="pages" name='pages' value="${pages}"/><!--总页数-->
            <sf:input id="moduleId" type="hidden" path="moduleId"/><!--模块id-->
            <c:if test="${msg != null}"><h3 style="color: #0FB492">${msg}</h3></c:if>
            <sf:input style="width: 150px" path="moduleName" type="text" placeholder="模块名称"/>
            <span style="color: red"></span>
            <sf:input style="width: 150px" path="projectName" type="text" placeholder="归属项目..."/>
            <c:if test="${userLogin.empRole.equals('1')}">
                <sf:input style="width: 150px" path="empName" type="text" placeholder="员工"/>
            </c:if>
            <input style="width: 95px" class="sang_Calender" name="begin" type="text" value="<fmt:formatDate value="${begin}" pattern="yyyy-MM-dd" />" placeholder="创建时间...">~
            <input style="width: 95px" class="sang_Calender" name="end" type="text" value="<fmt:formatDate value="${end}" pattern="yyyy-MM-dd" />" placeholder="创建时间...">
            <button type="submit" class="one"><span class="fa fa-search"></span></button>
                </c:if>
        </sf:form>
    <!--表格-->
    <div class="well" id="selBox">
    <c:if test="${moduleList.isEmpty()}"><h3 style="text-align: center">模块信息不存在</h3></c:if>
    <c:if test="${!moduleList.isEmpty()}">
            <!--查询-->
            <table class="table" id="now">
                <thead>
                <tr>
                    <th class="vvv">模块名称</th>
                    <th class="vvv">计划（比例）</th>
                    <th class="vvv">实际（比例）</th>
                    <th class="vvv">归属项目</th>
                    <c:if test="${userLogin.empRole.equals('1')}">
                        <th class="vvv">负责人</th>
                    </c:if>
                    <th class="vv">所在周期</th>
                    <p:power jspPower="模块：删除">
                    <th class="vv">删除</th>
                    </p:power>
                    <p:power jspPower="模块：修改">
                    <th class="vv">修改</th>
                    </p:power>
                    <p:power jspPower="模块：修改">
                    <th class="vv">详情</th>
                    </p:power>
                </tr>
                </thead>
                <tbody>
                <c:forEach var="m" items="${moduleList}">
                    <tr>
                        <td>${m.moduleName}</td>
                        <td>${m.modulePlan}%</td>
                        <td>${m.moduleActual}%</td>
                        <td>${m.project.projectName}</td>
                        <c:if test="${userLogin.empRole.equals('1')}">
                            <td>${m.emp.empName}</td>
                        </c:if>
                        <td>${m.moduleTimeBegin}至${m.moduleTimeEnd}</td>
                        <p:power jspPower="模块：删除">
                            <td>
                                <a onclick="deleteCheck(${m.moduleId})" role="button" data-toggle="modal"><i class="fa fa-times"></i></a>&nbsp;
                            </td>
                        </p:power>
                        <p:power jspPower="模块：修改">
                            <td>
                                <a href="${pageContext.request.contextPath}/Module/moduleEdit.emp?moduleId=${m.moduleId}"><i class="fa fa-pencil"></i></a>
                            </td>
                        </p:power>
                        <p:power jspPower="模块：详情">
                            <td>
                                <a href="${pageContext.request.contextPath}/Module/selById.emp?moduleId=${m.moduleId}"><i class="fa fa-flag"></i></a>
                            </td>
                        </p:power>
                    </tr>
                </c:forEach>
                </tbody>
            </table>
    </c:if>
    </div>
    <div class="well" id="addBox" style="display: none">
        <c:if test="${module.stageList.isEmpty()}"><h3 style="text-align: center">阶段信息不存在</h3></c:if>
        <c:if test="${!module.stageList.isEmpty()}">
            归属项目：${module.project.projectName} 归属模块：${module.moduleName}
            <table class="table" id="now">
                <thead>
                <tr>
                    <th class="vv">计划（比例）</th>
                    <th class="vv">实际（比例）</th>
                    <th class="vv">所属周期</th>
                </tr>
                </thead>
                <tbody>
                <c:forEach items="${module.stageList}" var="i">
                    <tr>
                        <td>${i.stagePlan}</td>
                        <td>${i.stageActual}</td>
                        <td>${i.stageWeekBegin}至${i.stageWeekEnd}</td>
                    </tr>
                </c:forEach>
                </tbody>
            </table>
        </c:if>
    </div>
        <c:if test="${pages > 1}">
            <div style="float: right">
                <ul class="pagination">
                    <page:paging length="10" page="${page}" pages="${pages}"/>
                </ul>
            </div>
        </c:if>
    </div>
</div>
<script type="text/javascript" src="${pageContext.request.contextPath}/dist/backEnd/js/datetime.js"></script>
</body>
</html>
